import type { IPSet, IPSetInfo, UserInfo } from "../../api/types";
import type { ACTIONS } from "./constants";

export interface RootState {
  user?: UserInfo | null | undefined;
  ipsets?: Record<string, IPSet> | null | undefined;
  ipsetInfo: Record<string, IPSetInfo>;
}

export interface LogoutAction {
  type: ACTIONS.LOGOUT;
}

export interface SetUserInfoAction {
  type: ACTIONS.SET_USERINFO;
  user: UserInfo | null;
}

export interface SetIPSetsAction {
  type: ACTIONS.SET_IPSETS;
  ipsets: Record<string, IPSet> | null;
}

export interface SetIPSetInfoAction {
  type: ACTIONS.SET_IPSETINFO;
  setname: string;
  info: IPSetInfo | null;
}

export type ActionTypes =
  | SetUserInfoAction
  | LogoutAction
  | SetIPSetsAction
  | SetIPSetInfoAction;

export interface RootProviderProps {
  children: React.ReactNode;
}
